package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);not null"`
	Password string `gorm:"type:char(32);not null"`
}

type Goods struct {
	gorm.Model
	Name       string  `gorm:"type:varchar(30);not null"`
	Price      float64 `gorm:"type:decimal(10,2);not null"`
	Image      string  `gorm:"type:varchar(255);not null"`
	Stock      int     `gorm:"type:int;not null"`
	Status     int     `gorm:"type:tinyint(1);not null"`
	CategoryId int     `gorm:"type:int(11);not null"`
}

type Cart struct {
	gorm.Model
	UserId   int `gorm:"type:int;not null"`
	GoodId   int `gorm:"type:int;not null"`
	Quantity int `gorm:"type:int;not null"`
}

func (g *Goods) GoodsAdd() error {
	return DB.Create(g).Error
}
